<?php
/*
 * 会员首页
 * @arrange Mark
 * @package ixdcw
 * @file    index.inc.php
 * @time    12-12-19 上午11:44
 */
defined('IN_IXDCW') or exit('Access Denied');
if(!$_userid) dheader(url('member/my'));
require DT_CORE.'/'.$module.'/common.inc.php';
require DT_CORE.'/'.$module.'/member.class.php';
if($action == 'logout' && $admin_user) {
	Cookie::set('admin_user', '');
	dmsg($L['index_msg_logout'], $MODULE[2]['linkurl']);
}
include_once DT_ROOT . '/module/extend/subscribe.inc.php';
require_once DT_INC.'/post.func.php';
$do = new member();
$do->userid = $_userid;
$user = $do->get_one();
$head_title = '';

$subAttention = $user['attention'];
if (!$subAttention) {
	$subAttention = array();
	foreach($MODULE as $k => $v) {
		if ($v['issubscribe']) {
			$subAttention[] =$k;
		}
	}
}
$subAll = array();

foreach($subAttention as $k => $v) {
	// unset mall Module
	if ($v==16) {
		unset($subAttention[$k]);
	} else {
		$tmpArr = PCache::read("$v.php", 'subscribe');
		if ($tmpArr) {
			foreach($tmpArr as $nk => $nv) {
				$nv['moduleid'] = $v;
				$subAll[] = $nv;
			}
		}

	}
}
shuffle($subAll);
$subContents = array_splice($subAll, 0, 16);

foreach($subContents as $k => $v) {
	if (strpos($v['linkurl'], SITE_URL) === false) {
		$subContents[$k]['linkurl'] = $v['linkurl'];
	}
}
extract($user);
$logintime = timetodate($logintime, 5);
$regtime = timetodate($regtime, 5);
$userurl = userurl($_username, '', $domain);
$sys = array();
$i = 0;
$result = $db->query("SELECT itemid,title,addtime,groupids FROM {$db->getPre()}message WHERE groupids!='' ORDER BY itemid DESC", 'CACHE');
while($r = $db->fetchArray($result)) {
	$groupids = explode(',', $r['groupids']);
	if(!in_array($_groupid, $groupids)) continue;
	if($i > 2) continue;
	$i++;
	$sys[] = $r;
}
$expired = $totime && $totime < $DT_TIME ? true : false;
$havedays = $expired ? 0 : ceil(($totime-$DT_TIME)/86400);
include template('index', $module);
